package acm.力扣391周赛;

import org.junit.Test;
//https://leetcode.cn/contest/weekly-contest-391/problems/water-bottles-ii/
public class 哈沙德数 {
    public int sumOfTheDigitsOfHarshadNumber(int x) {
        int n=x;
        int sum=0;
        while (n>0){
            sum+=n%10;
            n/=10;
        }
        return x%sum==0?sum:-1;
    }
    @Test
    public void test(){
        int i = sumOfTheDigitsOfHarshadNumber(23);
        System.out.println(i);
    }
}
